import React, { useState }  from 'react';
import './index.less';
import api from '../../../axios'
import { Button, Image,
  Descriptions,
Upload, } from 'antd';
import EditModal from '../components/editSwiper'



class index extends React.Component {
    constructor(props) {
        super(props);
        this.state = { 
            visible: false,
            loading: true,
            fileloading: false,
            imageUrl: '',
            initialValues: {},
            data: "",
            editModalVis: false,
        };
    }

    showModal = () => {
        this.setState({
            visible: true,
        });
    };
    
    hideModal = () => {
        this.setState({
            visible: false,
        });
    };

    componentDidMount(){
        this.getData()
    }

    
    getData = async () => {

      let res = await api.ajax({
          method: 'get',
          url: `/config/docking_pf`,
      });

      this.setState({
          data: res.data.value,
          loading: false
      })
    }

    editMoadl = (record) => {
      this.setState({
        initialValues: record,
        editModalVis: true
      })
    }


    onOk = () => {

    }
    
    render() {
    
      const { data, visible, editModalVis } = this.state

        return (
           <>
             <div className='wapper'>
                <div className='header_title'>
                    <Button type="primary" onClick={() => this.setState({ editModalVis: true }) }>修改对接平台信息</Button>
                </div>
                <div>
                  <Descriptions title="对接平台">
                    <Descriptions.Item label="内容">{ data }</Descriptions.Item>

                  </Descriptions>
                </div>
             </div>
                
              {
                editModalVis && 
                <EditModal
                  initialValues={{'value': data}}
                  cancelModal={() => {
                    this.setState({ editModalVis: false, pagination: { current: 1, size: 20 } })
                    this.getData()
                  }}
                />
              }


           </>
        );
    }
}

export default index;